

package com.hazelcast.query.impl.extractor.predicates;

import java.io.Serializable;
import java.util.Objects;

/**
 * Data structure used in the tests of extraction in single-value attributes (not in collections).
 */
public final class SingleValueDataStructure {

    private SingleValueDataStructure() {
    }

    public static Person person(Integer iq) {
        Brain brain = new Brain();
        brain.iq = iq;
        brain.name = "brain" + iq;
        Person person = new Person();
        person.brain = brain;
        return person;
    }

    public static class Person implements Serializable {

        Brain brain;

        @Override
        public boolean equals(Object o) {
            if (!(o instanceof Person other)) {
                return false;
            }
            return Objects.equals(this.brain, other.brain);
        }

        @Override
        public int hashCode() {
            return Objects.hashCode(brain);
        }
    }

    public static class Brain implements Serializable {

        Integer iq;
        String name;

        @Override
        public boolean equals(Object o) {
            if (!(o instanceof Brain other)) {
                return false;
            }
            return Objects.equals(this.iq, other.iq);
        }

        @Override
        public int hashCode() {
            return Objects.hashCode(iq);
        }
    }
}
